package scu.maqiang.fes;

public class Materials {
	public static double[][] ElasticConstituteMatrix(double E, double Nu, BVPType tp) {
		double mu = E / (2 * (1 + Nu));
		double lambda0 = E * Nu / ((1 + Nu)*(1 - 2 * Nu));
		double lambda1 = E * Nu / (1 - Nu*Nu);
		double[][] D;
		switch (tp) {
			case PLANESTRAIN -> {
				D = new double[3][3];
				D[0][0] = D[1][1] = lambda0 + 2 * mu;
				D[0][1] = D[1][0] = lambda0;
				D[2][2] = mu;
			}
			case PLANESTRESS -> {
				D = new double[3][3];
				D[0][0] = D[1][1] = lambda1 + 2 * mu;
				D[0][1] = D[1][0] = lambda1;
				D[2][2] = mu;
			}
			case COMMON -> {
				D = new double[6][6];
				D[0][0] = D[1][1] = D[2][2] = lambda0 + 2 * mu;
				D[0][1] = D[1][0] = lambda0;
				D[0][2] = D[2][0] = lambda0;
				D[1][2] = D[2][1] = lambda0;
				D[3][3] = D[4][4] = D[5][5] = mu;
			}
			case AXISYMMETRIC -> {
				D = new double[4][4];
				D[0][0] = D[1][1] = D[2][2] = lambda0 + 2 * mu;
				D[0][1] = D[1][0] = lambda0;
				D[0][2] = D[2][0] = lambda0;
				D[1][2] = D[2][1] = lambda0;
				D[3][3] = mu;
			}
			case AXIS_PLANESTRAIN -> {
				D = new double[2][2];
				D[0][0] = D[1][1] = lambda0 + 2 * mu;
				D[1][0] = D[0][1] = lambda0;
			}
			case AXIS_PLANESTRESS -> {
				D = new double[2][2];
				D[0][0] = D[1][1] = lambda1 + 2 * mu;
				D[1][0] = D[0][1] = lambda1;
			}
			case SPHERICAL -> {
				D = new double[2][2];
				D[0][0] = lambda0 + 2 * mu;
				D[1][0] = D[0][1] = 2 * lambda0;
				D[1][1] = 4 * (lambda0 + mu);
			}
			default -> throw new IllegalArgumentException("Wrong Type");
		}
		return D;
	}

	public static double[][] PEConstituteMatrix_LiTaO3() {
		return new double[][]{
				{   -40.9,        0,         0,             0,            0,            0,             0,       2.59576,      -1.58923},
				{       0,    -40.9,         0,      -1.58923,      1.58923,            0,       2.59576,             0,             0},
				{       0,        0,     -43.3,     0.0821598,    0.0821598,      1.88197,             0,             0,             0},
				{       0, -1.58923, 0.0821598,  2.32966e+011, 4.68904e+010, 8.02342e+010, -1.10267e+010,             0,             0},
				{       0,  1.58923, 0.0821598,  4.68904e+010, 2.32966e+011, 8.02342e+010,  1.10267e+010,             0,             0},
				{       0,        0,   1.88197,  8.02342e+010, 8.02342e+010, 2.75364e+011,             0,             0,             0},
				{       0,  2.59576,         0, -1.10267e+010, 1.10267e+010,            0,  9.38995e+010,             0,             0},
				{ 2.59576,        0,         0,             0,            0,            0,             0,  9.38995e+010, -1.10267e+010},
				{-1.58923,        0,         0,             0,            0,            0,             0, -1.10267e+010,   9.3038e+010}
		};
	}

	public static double[][] ElasticConstituteMatrix_LiTaO3() {
		return new double[][] {
				{ 2.32966e+011, 4.68904e+010, 8.02342e+010, -1.10267e+010,             0,             0},
				{ 4.68904e+010, 2.32966e+011, 8.02342e+010,  1.10267e+010,             0,             0},
				{ 8.02342e+010, 8.02342e+010, 2.75364e+011,             0,             0,             0},
				{-1.10267e+010, 1.10267e+010,            0,  9.38995e+010,             0,             0},
				{            0,            0,            0,             0,  9.38995e+010, -1.10267e+010},
				{            0,            0,            0,             0, -1.10267e+010,   9.3038e+010}
		};
	}

	public static double[][] ElasticConstituteMatrix_Si(BVPType tp) {
		double E_Si = 1.6e11;
		double Nu_Si = 0.22;
		return ElasticConstituteMatrix(E_Si, Nu_Si, tp);
	}

	public static double[][] ElasticConstituteMatrix_Al(BVPType tp) {
		double E_Al = 7.0e9;
		double Nu_Al = 0.35;
		return ElasticConstituteMatrix(E_Al, Nu_Al, tp);
	}
	
}
